package com.sjz.bookmark.tree;

import cn.hutool.core.util.StrUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleTextAttributes;
import com.sjz.bookmark.mysql.BookmarkRecord;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class BookmarkTreeCellRenderer extends ColoredTreeCellRenderer {
    @Override
    public void customizeCellRenderer(@NotNull JTree tree, Object value,
                                    boolean selected, boolean expanded,
                                    boolean leaf, int row, boolean hasFocus) {
        if (!(value instanceof BookmarkRecord)){
            return;
        }
        BookmarkRecord bookmarkRecord = (BookmarkRecord) value;
        // 书签节点样式
        if (bookmarkRecord.getName()==null){
            return;
        }
        append(bookmarkRecord.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        setIcon(AllIcons.Nodes.Bookmark);

    }
}